package lab4;
/*
 * Main.fx
 *
 * Created on 01.12.2009, 16:52:40
 */

import javafx.animation.Timeline;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.shape.Rectangle;
import javafx.scene.shape.Line;
import javafx.scene.transform.Rotate;




/**
 * @author Сергей
 */






var k=0;
var r=0;


var car1:ImageView= ImageView{
x: 400
y:0
fitWidth:100
fitHeight: 150
  image: Image {
  url: "{__DIR__}12.jpg"}
  transforms: Rotate { pivotX :bind car1.x, pivotY : bind car1.y, angle:bind k }
}
var car2:ImageView= ImageView{
x:  840
y:  240
fitWidth:150
fitHeight: 100
  image: Image {
  url: "{__DIR__}13.jpg"}
  transforms:  Rotate { pivotX : 0.0, pivotY : 0.0, angle: 0.0 }

}

var move:ImageView= ImageView{
x:0
y:370
fitWidth:150
fitHeight: 100
  image: Image {
  url: "{__DIR__}11.jpg"}

     onMouseClicked: function( e: MouseEvent ):Void {
   delete move from   animated.scene.content
  }



                             }

var time:Timeline=Timeline {
    repeatCount: Timeline.INDEFINITE;
    keyFrames : [
          
           at (1s)  {move.x=>300;}
           at (2s)  {move.x=>500;}
           at (3s)  {move.x=>1200;}
           at (1s)  {car2.x=>400;}
           at (4s)  {car2.x=>-150;}
           at (2s)  {k=>90;}
           at (3s)  {car1.x=>-10;}
           at (2s)  {car1.y=>260;}
           at (2.4s) {car1.y=>243;}
      
]

}
time.play();
var animated:Stage=Stage {


    title: "Laba4"
    width: 1000
    height: 600
    scene: Scene {
        content: [

                Rectangle {
                x: 0, y: 0
                width: 1010, height: 610
                fill: Color.GREY
        }

        Line {
                startX: 0, startY: 480
                endX: 1010, endY: 480
                strokeWidth: 7
                stroke: Color.WHITE
        }

        Line {
                startX: 616, startY: 229
                endX: 1010, endY: 229
                strokeWidth: 7
                stroke: Color.WHITE
        }



        Line {
                startX: 0, startY: 349
                endX: 330, endY: 349
                strokeWidth: 4
                stroke: Color.WHITE
        }
        Line {
                startX: 0, startY: 230
                endX: 330, endY: 230
                strokeWidth: 7
                stroke: Color.WHITE
        }



        Line {
                startX: 600, startY: 349
                endX: 1010, endY: 349
                strokeWidth: 4
                stroke: Color.WHITE
        }


        Line {
                startX: 330, startY: 229
                endX: 330, endY: 0
                strokeWidth: 7
                stroke: Color.WHITE
        }
        Line {
                startX: 468, startY: 229
                endX: 468, endY: 0
                strokeWidth: 4
                stroke: Color.WHITE
        }
        Line {
                startX: 612, startY: 229
                endX: 612, endY: 0
                strokeWidth: 7
                stroke: Color.WHITE
        }







         move ,car1,car2




        ]
    }
}